package com.example.springboot1.controller;

import com.example.springboot1.Service.CityService;
import com.example.springboot1.pojo.City;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CityController {
    @Autowired
    private CityService cityService;
    @GetMapping("/get/{id}")
    public City getById(@PathVariable("id") Integer id) {
        System.out.println(id);
        return cityService.getCityById(id);
    }
    @GetMapping("/insertCity")
    public int InsertCity(@RequestBody City city) {
        int i = cityService.InsertCity(city);
        return i;
    }

    @GetMapping("/updateCity")
    public int updateCity(@RequestBody City city) {
        int i = cityService.updateCity(city);
        return i;
    }

    @GetMapping("/deleteCity/{id}")
    public int deleteCity(@PathVariable("id") Integer id) {
        return cityService.deleteCity(id);
    }
}
